package com.ruoyi.cbs.contract.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cbs.contract.mapper.ContractorEquipmentMapper;
import com.ruoyi.cbs.contract.domain.ContractorEquipment;
import com.ruoyi.cbs.contract.service.IContractorEquipmentService;

/**
 * 承包商器具Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-11-21
 */
@Service
public class ContractorEquipmentServiceImpl implements IContractorEquipmentService 
{
    @Autowired
    private ContractorEquipmentMapper contractorEquipmentMapper;

    /**
     * 查询承包商器具
     * 
     * @param id 承包商器具主键
     * @return 承包商器具
     */
    @Override
    public ContractorEquipment selectContractorEquipmentById(Long id)
    {
        return contractorEquipmentMapper.selectContractorEquipmentById(id);
    }

    /**
     * 查询承包商器具列表
     *
     * @param contractorId 承包商ID
     * @return 承包商器具
     */
    @Override
    public List<ContractorEquipment> selectListByContractorId(Long contractorId)
    {
        ContractorEquipment contractorEquipment = new ContractorEquipment();
        contractorEquipment.setContractorId(contractorId);
        contractorEquipment.setStatus("1");
        return selectContractorEquipmentList(contractorEquipment);
    }

    /**
     * 查询承包商器具列表
     * 
     * @param contractorEquipment 承包商器具
     * @return 承包商器具
     */
    @Override
    public List<ContractorEquipment> selectContractorEquipmentList(ContractorEquipment contractorEquipment)
    {
        return contractorEquipmentMapper.selectContractorEquipmentList(contractorEquipment);
    }

    /**
     * 新增承包商器具
     * 
     * @param contractorEquipment 承包商器具
     * @return 结果
     */
    @Override
    public int insertContractorEquipment(ContractorEquipment contractorEquipment)
    {
        contractorEquipment.setCreateTime(DateUtils.getNowDate());
        contractorEquipment.setId(IdFactory.newLongId());
        if (contractorEquipment.getCreateBy() == null) {
            contractorEquipment.setCreateBy("admin");
        }
        return contractorEquipmentMapper.insertContractorEquipment(contractorEquipment);
    }

    /**
     * 修改承包商器具
     * 
     * @param contractorEquipment 承包商器具
     * @return 结果
     */
    @Override
    public int updateContractorEquipment(ContractorEquipment contractorEquipment)
    {
        contractorEquipment.setUpdateTime(DateUtils.getNowDate());
        return contractorEquipmentMapper.updateContractorEquipment(contractorEquipment);
    }

    /**
     * 批量删除承包商器具
     * 
     * @param ids 需要删除的承包商器具主键
     * @return 结果
     */
    @Override
    public int deleteContractorEquipmentByIds(Long[] ids)
    {
        return contractorEquipmentMapper.deleteContractorEquipmentByIds(ids);
    }

    /**
     * 删除承包商器具信息
     * 
     * @param id 承包商器具主键
     * @return 结果
     */
    @Override
    public int deleteContractorEquipmentById(Long id)
    {
        return contractorEquipmentMapper.deleteContractorEquipmentById(id);
    }
}
